﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace nadModel.pad
{
    public partial class StockProcess : AbstractEntityProcess
    {
        public string conection_addr = "http://nad.nadfinlo.com.cn/nad/";
        public StockEntity[] FindByParameter(StockParameter p)
        {
            string sql = " select * from " + StockEntity.DB_TABLES + " where company='" + p.company + "' "
                              + "  and (" + StockEntity.PART_NUM + " >='" + p.PartNumFrom + "' or '" + p.PartNumFrom + "' ='') "
                              + "  and (" + StockEntity.PART_NUM + " <='" + p.PartNumTo + "' or '" + p.PartNumTo + "' ='') "
                              + "  and (" + StockEntity.OLD_PART_NUM + " ='" + p.OldPart + "' or '" + p.OldPart + "' ='') "
                              + "  and (" + StockEntity.PART_DESCRIPTION + "  like N'%" + p.PartDesc + "%' or '" + p.PartDesc + "' ='') "
                              + "  and (" + StockEntity.WAREHOUSE_CODE + "  >='" + p.WhseFrom + "' or '" + p.WhseFrom + "' ='') "
                              + "  and (" + StockEntity.WAREHOUSE_CODE + "  <='" + p.WhseTo + "' or '" + p.WhseTo + "' ='') "
                              + "  and (" + StockEntity.BIN_NUM + "  >='" + p.BinFrom + "' or '" + p.BinFrom + "' ='') "
                              + "  and (" + StockEntity.BIN_NUM + "  <='" + p.BinTo + "' or '" + p.BinTo + "' ='') "
                              + "  and (" + StockEntity.PROD_CODE + "  ='" + p.GroupId + "' or '" + p.GroupId + "' ='') "
                              + "  and (" + StockEntity.CLASS_ID + "  ='" + p.ClassId + "' or '" + p.ClassId + "' ='') "
                              + "  and (" + StockEntity.RUN_OUT + "  ='" + p.RunOut + "' or '" + p.RunOut + "' ='') "
                              + "  and (right(" + StockEntity.PART_NUM + ",2)  ='" + p.CB + "' or '" + p.CB + "' ='') ";

            StockEntity[] ents = (StockEntity[])FindBySql(sql,conection_addr);
            return ents;
        }


    }
}
